package com.disgnpattern.learn.chapter13;

import javax.swing.*;
import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;

/**
 * @author dxy
 * @version 1.0
 * @date 2021/11/19 16:29
 * @descrition
 * @Version 1.0
 * @mail victorydeng@163.com
 */
public class BuidTest extends JFrame{

    public BuidTest(){
        super();
        //调用初始化方法
        initialize();
    }
    //初始化方法
    private void initialize(){
        //设置窗体的大小
        this.setSize(300, 200);
        //设置窗体的关闭方式
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //设置窗体面板为绘图面板对象
        setContentPane(new DrawPanel());
        //设置窗体标题
        this.setTitle("造人1");
    }

    class DrawPanel extends JPanel{
        @Override
        public void paint(Graphics g){
            super.paint(g);
            //头
            g.drawOval(50, 20, 30, 30);
            //身体
            g.drawRect(60,50,10,50);
            //左手
            g.drawLine(60,50,40,100);
            //右手
            g.drawLine(70,50,90,100);
            //左脚
            g.drawLine(60,100,45,150);
            //右脚
            g.drawLine(70,100,85,150);
        }
    }
    public static void main(String[] args) {
        //初始化对象且调用构造方法
        BuidTest dc=new BuidTest();
        //窗体可视化
        dc.setVisible(true);
    }

}